home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST8-13.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  988b  |  39 lines

  1. ;
  2. ; *** Listing 8-13 ***
  3. ;
  4. ; Adds together bytes from two arrays, subtracts a byte from
  5. ; another array from the sum, and stores the result in a fourth
  6. ; array, for all elements in the arrays.
  7. ; Uses the mod-reg-rm form of XCHG.
  8. ;
  9.     jmp    Skip
  10. ;
  11. ARRAY_LENGTH    equ    1000
  12. Array1    db    ARRAY_LENGTH dup (3)
  13. Array2    db    ARRAY_LENGTH dup (2)
  14. Array3    db    ARRAY_LENGTH dup (1)
  15. Array4    db    ARRAY_LENGTH dup (?)
  16. ;
  17. Skip:
  18.     mov    dx,offset Array1
  19.     mov    bx,offset Array2
  20.     mov    si,offset Array3
  21.     mov    di,offset Array4
  22.     mov    cx,ARRAY_LENGTH
  23.     call    ZTimerOn
  24. ProcessingLoop:
  25.     xchg    dx,bx        ;point BX to Array1,
  26.                 ; point DX to Array2
  27.     mov    al,[bx]        ;get next byte from Array1
  28.     xchg    dx,bx        ;point BX to Array2,
  29.                 ; point DX to Array1
  30.     add    al,[bx]        ;add Array2 element to Array1
  31.     sub    al,[si]        ;subtract Array3 element
  32.     mov    [di],al        ;store result in Array4
  33.     inc    dx        ;point to next element of each array
  34.     inc    bx        
  35.     inc    si        
  36.     inc    di
  37.     loop    ProcessingLoop    ;do the next element
  38.     call    ZTimerOff
  39.